/**
 * 
 */
package fr.cephb.operonj.core.db.comparator;

import java.io.Serializable;
import java.util.Comparator;

import com.sleepycat.bind.tuple.TupleInput;

import fr.cephb.operonj.core.bio.ChromPosition;
import fr.cephb.operonj.core.db.binding.ChromPositionBinding;


/**
 * ChromPositionComparator
 *
 */
public class ChromPositionComparator
	implements Comparator<byte[]>,Serializable
	{
	private static final long serialVersionUID = 1L;
	public ChromPositionComparator()
		{
		}
	
	@Override
	public int compare(byte[] o1, byte[] o2)
		{
		ChromPositionBinding binding= new ChromPositionBinding();
		ChromPosition t1= binding.entryToObject(new TupleInput(o1));
		ChromPosition t2= binding.entryToObject(new TupleInput(o2));
		int n=t1.getChromId()-t2.getChromId();
		if(n!=0) return n;
		return t1.getPosition()-t2.getPosition();
		}
	}
